Interface ControllerTester

Summary

Fully Qualified Name: CodeIgniter\Test\ControllerTester

Description

ControllerTester Trait

Provides features that make testing controllers simple and fluent.

Example:

$this->withRequest($request)

  ->withResponse($response)
  ->withURI($uri)
  ->withBody($body)
  ->controller('App\Controllers\Home')
  ->run('methodName');

Methods

Name Description Defined By
controller() Loads the specified controller, and generates any needed dependencies. ControllerTester
execute() Runs the specified method on the controller and returns the results. ControllerTester
withBody() Set the method's body, with method chaining. ControllerTester
withConfig() Set controller's config, with method chaining. ControllerTester
withLogger() Set controller's logger, with method chaining. ControllerTester
withRequest() Set controller's request, with method chaining. ControllerTester
withResponse() Set controller's response, with method chaining. ControllerTester
withUri() Set the controller's URI, with method chaining. ControllerTester

Method Details

controller()

Loads the specified controller, and generates any needed dependencies.

Parameter Name Type Description
$name string

Returns: mixed

execute()

Runs the specified method on the controller and returns the results.

Parameter Name Type Description
$method string
$params array

Returns: \CodeIgniter\Test\ControllerResponse|\InvalidArgumentException

withBody()

Set the method's body, with method chaining.

Parameter Name Type Description
$body mixed

Returns: mixed

withConfig()

Set controller's config, with method chaining.

Parameter Name Type Description
$appConfig mixed

Returns: mixed

withLogger()

Set controller's logger, with method chaining.

Parameter Name Type Description
$logger mixed

Returns: mixed

withRequest()

Set controller's request, with method chaining.

Parameter Name Type Description
$request mixed

Returns: mixed

withResponse()

Set controller's response, with method chaining.

Parameter Name Type Description
$response mixed

Returns: mixed

withUri()

Set the controller's URI, with method chaining.

Parameter Name Type Description
$uri string

Returns: mixed

Top